<!--
 * @Author: ellery
 * @Date: 2022-08-26 22:40:08
 * @LastEditTime: 2022-08-28 00:42:22
 * @LastEditors: ellery
 * @Description:
 * @FilePath: \vue2-eslint-model\src\views\Login.vue
 * Copyright (c) 2022 by ellery, All Rights Reserved.
 * 愿天堂没代码
-->
<template>
  <div>
    <h1>{{ $route.meta.label }}</h1>
    <div @click="toRouter">跳转到首页页面</div>
    <div @click="toNoPermission">跳转到无权限得页面</div>
    <div @click="getData">请求获取数据，请在打印台查看</div>
  </div>
</template>

<script>
export default {
  name: "Home",
  $$route: {
    name: "/",
    lazy: true,
    meta: {
      label: "登录",
      isKey: true // 判断是否有权限打开
    }
  },
  data() {
    return {};
  },

  mounted() {
    console.log(this.$store.state.test.testState);
    console.log(this.$store.getters["test/testGetters"]);
    this.$store.commit("test/SET_MUTATIONS", "mutations");
    console.log(this.$store.state.test.testMutations);
    this.$store.dispatch("test/SET_ACTION_ACTIONS", "2s后变了");
    console.log(this.$store.state.test.testActions);
  },

  methods: {
    toRouter() {
      this.$router.push({
        name: "Main",
        query: { id: "1", url: process.env.VUE_APP_BASE_URL }
      });
    },
    toNoPermission() {
      this.$router.push({ name: "Tests" });
    },
    async getData() {
      const res = await this.$api.test();
      console.log(res, "=>获取数据");
    }
  }
};
</script>

<style lang="scss" scoped></style>
